﻿using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

using CE.User;
using CE.Global;
using CE.Database;
using CE.Provider;
using CE.CarInsurance;
using CE.Company;
using CE.Mail;
using CE.InputOut;

public partial class car_insurance_quote_results_details : MyLanguageAndSessionBasePage
{
    string _redirectUrl = "";
    protected void Page_Init(object sender, EventArgs e)
    {
        GetResultDetails();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        Master.Page.Title = Resources.Title.QuoteResultsDetailsTitle;

        LiteralControl newln = new LiteralControl(Environment.NewLine);
        HtmlMeta language = new HtmlMeta();
        language.Name = "language";
        language.Content = Resources.Title.PageLanguage;

        HtmlMeta keywords = new HtmlMeta();
        keywords.Name = "keywords";
        keywords.Content = Resources.Title.QuoteResultsDetailsKeyword;

        HtmlMeta description = new HtmlMeta();
        description.Name = "description";
        description.Content = Resources.Title.QuoteResultsDetailsDescription;

        Page.Header.Controls.AddAt(10, new LiteralControl(Environment.NewLine));
        Page.Header.Controls.AddAt(11, language);
        Page.Header.Controls.AddAt(12, new LiteralControl(Environment.NewLine));
        Page.Header.Controls.AddAt(13, keywords);
        Page.Header.Controls.AddAt(14, new LiteralControl(Environment.NewLine));
        Page.Header.Controls.AddAt(15, description);

        if (!Page.IsPostBack)
        {
            if (Session[General.UserName] != null)
            {
                //Popup
                txtFullName.Text = Session[General.UserName].ToString();
                txtMobileNo.PhoneNo = Session[General.UserPhoneNo].ToString();
                txtEmail.Text = Session[General.UserEmail].ToString();

                GetCarMakeModel();
            }
            else
            {
                _redirectUrl = CE.Global.General.GetUrl("~/car-insurance/login.aspx", Page);
                Response.Redirect(_redirectUrl);
            }
        }



    }

    private void GetCarMakeModel()
    {
        CarDetailTH _cardetail = new CarDetailTH();
        CarDetailTHDB _cardetaildb = new CarDetailTHDB();

        _cardetail = _cardetaildb.GetCar(Convert.ToInt64(Session[General.CarId].ToString()), Convert.ToInt64(Session[General.UserId].ToString()));
        if (_cardetail != null)
        {
            inputCallMeMakeModel.Value = _cardetail.MakeModelDesc;
        }
    }

    private void GetResultDetails()
    {
        if (Session["CarSelected"] != null && Session[General.UserId] != null && Session[General.CarId] != null && Session[General.UserName] != null)
        {
            if (Cache["CarResult" + Session[General.UserId].ToString() + Session[General.CarId].ToString()] != null)
            {
                DataView dv = new DataView((DataTable)Cache["CarResult" + Session[General.UserId].ToString() + Session[General.CarId].ToString()]);

                string CITempResultId = Session["CarSelected"].ToString();

                dv.RowFilter = " CITempResultId in (" + CITempResultId.Remove(CITempResultId.Length - 1, 1) + ")";
                DataTable dtFiltered = dv.ToTable();
                if (Cache["CarResult" + Session[General.UserId].ToString() + Session[General.CarId].ToString()] != null)
                {
                    if (dtFiltered.Rows.Count > 0)
                    {
                        int rowCount = dtFiltered.Rows.Count;


                        for (int iRows = 0; iRows < rowCount; iRows++)
                        {

                            string _providercompanyid = dtFiltered.Rows[iRows]["ProviderCompanyId"].ToString();

                            //top
                            HtmlTableCell tcTop = new HtmlTableCell();
                            tcTop.Attributes.Add("class", "bg_grey_2 w210px");

                            HtmlGenericControl divTop = new HtmlGenericControl("div");

                            HtmlGenericControl divTop1 = new HtmlGenericControl("div");
                            divTop1.Attributes.Add("class", "curvetopleft left");

                            HtmlGenericControl divTop2 = new HtmlGenericControl("div");
                            divTop2.Attributes.Add("class", "curvetopright right");

                            divTop.Controls.Add(divTop1);
                            divTop.Controls.Add(divTop2);

                            tcTop.Controls.Add(divTop);

                            trTop.Controls.Add(tcTop);

                            //Provider Image Logo
                            HtmlTableCell tcProvider = new HtmlTableCell();
                            tcProvider.Attributes.Add("class", "bg_grey_2 h70px pad7px");
                            Image imgCompanyLogo = new Image();

                            if (dtFiltered.Rows.Count == 2)
                            {
                                imgCompanyLogo.Width = 140;
                            }
                            else if (dtFiltered.Rows.Count == 3)
                            {
                                imgCompanyLogo.Width = 130;
                            }
                            else if (dtFiltered.Rows.Count == 4)
                            {
                                imgCompanyLogo.Width = 115;
                            }
                            //imgCompanyLogo.ImageUrl = dtFiltered.Rows[iRows]["CompanyLogoUrl"].ToString();

                            imgCompanyLogo.ImageUrl = CE.Global.General.GetProviderCompanyLogo(_providercompanyid);

                            tcProvider.Controls.Add(imgCompanyLogo);
                            trProvider.Controls.Add(tcProvider);

                            //PlanName
                            HtmlTableCell tcPlan = new HtmlTableCell();
                            tcPlan.Attributes.Add("class", "bg_grey_3 border2pxdotb pad7px white");
                            tcPlan.InnerHtml = "<strong>" + dtFiltered.Rows[iRows]["packagename"].ToString() + "</strong>";

                            trPlan.Controls.Add(tcPlan);

                            //Premium
                            HtmlTableCell tcPrice = new HtmlTableCell();
                            tcPrice.Attributes.Add("class", "bg_grey_4 h70px border1pxdotb_dark pad7px");
                            HtmlGenericControl divPrice = new HtmlGenericControl("div");
                            divPrice.Attributes.Add("class", "");
                            string annualprice = string.Empty;
                            if (Convert.ToSingle(dtFiltered.Rows[iRows]["annualpremium"]) != Convert.ToSingle(dtFiltered.Rows[iRows]["promotionprice"]))
                            {
                                annualprice = "<div class=price_old>" + String.Format("{0:0,0.00}", Convert.ToSingle(dtFiltered.Rows[iRows]["annualpremium"].ToString())) + "</div>";
                            }
                            //annualprice = annualprice + "<div class=price><img src='/images/other/spacer.gif' alt='Only Online!' width='45' height='1'/>";
                            annualprice = annualprice + "<div class=price>";
                            annualprice = annualprice + String.Format("{0:0,0.00}", Convert.ToSingle(dtFiltered.Rows[iRows]["promotionprice"].ToString())); //"999.00";
                            annualprice = annualprice + "</div>";
                            //annualprice = annualprice + "<br/><img src='" + Resources.ImageResource .OnlineOnlyUrl +"' alt='Only Online!' width='45' height='30'/>";

                            divPrice.InnerHtml = annualprice;

                            tcPrice.Controls.Add(divPrice);
                            trPrice.Controls.Add(tcPrice);

                            //Installment
                            #region Installment

                            //HtmlTableCell tcInstallment = new HtmlTableCell();
                            //tcInstallment.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad7px");

                            //float _fMonthlyPremiumAmount = Convert.ToSingle(dtFiltered.Rows[iRows]["MonthlyPremiumAmount"].ToString());

                            //if (_fMonthlyPremiumAmount > 0.0f)
                            //{
                            //    string _monthlyPremiumAmount = String.Format("{0:0,0.00}", _fMonthlyPremiumAmount);

                            //    tcInstallment.InnerHtml = _monthlyPremiumAmount + "/mth<br/>";

                            //}
                            //else
                            //{
                            //    Image imgInstallment = new Image();
                            //    imgInstallment.ImageUrl = "/images/icon/X.png";
                            //    tcInstallment.Controls.Add(imgInstallment);
                            //}

                            //trInstallment.Controls.Add(tcInstallment);

                            #endregion

                            //Deductible- Excess
                            HtmlTableCell tcExcess = new HtmlTableCell();
                            tcExcess.Attributes.Add("class", "bg_grey_2 pad7px");
                            String dec = string.Empty;
                            if (Convert.ToSingle(dtFiltered.Rows[iRows]["DEC"].ToString()) == 0)
                            {
                                dec = Resources.CarInsuranceResultPage.Waived;
                            }
                            else
                            {
                                dec = String.Format("{0:0,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["DEC"].ToString()));
                            }
                            tcExcess.InnerText = dec;

                            trExcess.Controls.Add(tcExcess);

                            //SumInsured - OwnDamange
                            HtmlTableCell tcWP = new HtmlTableCell();
                            tcWP.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad7px");
                            if (Convert.ToSingle(dtFiltered.Rows[iRows]["SumInsured"].ToString()) == 0)
                            {
                                Image imgLossPE = new Image();
                                imgLossPE.ImageUrl = "/images/icon/X.png";
                                tcWP.Controls.Add(imgLossPE);
                            }
                            else
                            {
                                tcWP.InnerText = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["SumInsured"].ToString()));
                            }

                            trWorkshop.Controls.Add(tcWP);

                            //Fire
                            HtmlTableCell tcPA = new HtmlTableCell();
                            tcPA.Attributes.Add("class", "bg_grey_2 pad7px");
                            if (Convert.ToInt32(dtFiltered.Rows[iRows]["Fire"].ToString()) == 0)
                            {
                                Image imgLossPE = new Image();
                                imgLossPE.ImageUrl = "/images/icon/X.png";
                                tcPA.Controls.Add(imgLossPE);
                            }
                            else
                            {
                                tcPA.InnerText = String.Format("{0:#,0}", Convert.ToInt32(dtFiltered.Rows[iRows]["Fire"].ToString()));
                            }


                            trPA.Controls.Add(tcPA);

                            //Theft
                            HtmlTableCell tcPA2 = new HtmlTableCell();
                            tcPA2.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad7px");
                            if (Convert.ToSingle(dtFiltered.Rows[iRows]["Theft"].ToString()) == 0)
                            {
                                Image imgLossPE = new Image();
                                imgLossPE.ImageUrl = "/images/icon/X.png";
                                tcPA2.Controls.Add(imgLossPE);
                            }
                            else
                            {
                                tcPA2.InnerText = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["Theft"].ToString()));
                            }


                            trPA2.Controls.Add(tcPA2);

                            //MEdical Expense
                            HtmlTableCell tcMedExp = new HtmlTableCell();
                            tcMedExp.Attributes.Add("class", "bg_grey_2 pad7px");
                            tcMedExp.InnerText = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["TPPD"].ToString()));
                            trMedExp.Controls.Add(tcMedExp);
                            #region remove
                            //int _MedicalExpense = Convert.ToInt32(dtFiltered.Rows[iRows]["SumInsured"].ToString());

                            //if (_MedicalExpense == 0)
                            //{
                            //    Image imgMedExp = new Image();
                            //    imgMedExp.ImageUrl = "~/images/icon/X.png";
                            //    tcMedExp.Controls.Add(imgMedExp);
                            //}
                            //else
                            //{
                            //    tcMedExp.InnerText = String.Format("{0:#,0}", Convert.ToSingle(_MedicalExpense.ToString()));
                            //}

                            //trMedExp.Controls.Add(tcMedExp);
                            #endregion

                            //Loss of Personal Effects
                            HtmlTableCell tcLossPE = new HtmlTableCell();
                            tcLossPE.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad7px");
                            tcLossPE.InnerText = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["TPBIA"].ToString()));

                            trLossPE.Controls.Add(tcLossPE);

                            #region remove
                            //bool _IsPersonnalEffectsLoss = Convert.ToBoolean(dtFiltered.Rows[iRows]["IsPersonnalEffectsLoss"].ToString());

                            //if (!_IsPersonnalEffectsLoss)
                            //{
                            //    Image imgLossPE = new Image();
                            //    imgLossPE.ImageUrl = "~/images/icon/X.png";
                            //    tcLossPE.Controls.Add(imgLossPE);
                            //}
                            //else
                            //{
                            //    tcLossPE.InnerText = String.Format("{0:#,0}", Convert.ToSingle(_LossPE.ToString()));
                            //}

                            //trLossPE.Controls.Add(tcLossPE);
                            #endregion
                            //Loss of Use
                            HtmlTableCell tcLossUse = new HtmlTableCell();
                            tcLossUse.Attributes.Add("class", "bg_grey_2 pad7px");
                            tcLossUse.InnerText = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["TPBIP"].ToString()));

                            trLossOfUse.Controls.Add(tcLossUse);

                            #region remove
                            //string _CarReplace =  dtFiltered.Rows[iRows]["CarReplacement"].ToString();
                            //bool _IsCarReplace =  Convert.ToBoolean(dtFiltered.Rows[iRows]["IsCarReplacement"].ToString());
                            //bool _IsTranspoAllowance  = Convert.ToBoolean(dtFiltered.Rows[iRows]["isCashAllowance"].ToString());
                            //string _strTranspoAllowance  = Convert.ToString(dtFiltered.Rows[iRows]["CashAllowance"].ToString());
                            //string _strMaxTranspoAllowanceDays = Convert.ToString(dtFiltered.Rows[iRows]["MaxCashAllowanceDays"].ToString());

                            //if (_IsCarReplace)
                            //{
                            //    tcLossUse.InnerHtml = "Courtesy Car <br/>" + "max " + _CarReplace.ToString() + " day(s)";
                            //}
                            //else
                            //{
                            //    if (_IsTranspoAllowance)
                            //    {
                            //        tcLossUse.InnerHtml = "Transport Allowance<br/> S$" + _strTranspoAllowance + "/day <br/> max " + _strMaxTranspoAllowanceDays + " day(s)";
                            //    }
                            //    else
                            //    {
                            //        Image imgCarRep = new Image();
                            //        imgCarRep.ImageUrl = "~/images/icon/X.png";
                            //        tcLossUse.Controls.Add(imgCarRep);
                            //    }

                            //}

                            //trLossOfUse.Controls.Add(tcLossUse);
                            #endregion

                            //workshops pdf
                            HtmlTableCell tcWorkshopPDF = new HtmlTableCell();
                            tcWorkshopPDF.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad7px");
                            tcWorkshopPDF.InnerText = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["PADriver"].ToString()));
                            trWorkshopPDF.Controls.Add(tcWorkshopPDF);

                            #region remove
                            //Image imgWorkshops = new Image();
                            //HyperLink hlnkWorkshop = new HyperLink();
                            //hlnkWorkshop.ImageUrl = "~/images/icon/pdf.png";
                            //hlnkWorkshop.Target = "blank";

                            //if (_providercompanyid == "29")
                            //{
                            //    hlnkWorkshop.NavigateUrl = "http://www.libertyinsurance.com.sg/pdf/PWS%20Nov05.pdf";
                            //}
                            //else if (_providercompanyid == "30")
                            //{
                            //    hlnkWorkshop.NavigateUrl = "../policy_docs/Etiqa/Etiqa - AWS Listing.pdf";
                            //}
                            //else
                            //{
                            //    hlnkWorkshop.NavigateUrl = "../policy_docs/HSBC/HSBCworkshops.pdf";
                            //    //hlnkWorkshop.NavigateUrl = "javascript:OpenWorkshop(" + _providercompanyid.ToString() + ");";
                            //}

                            //tcWorkshopPDF.Controls.Add(hlnkWorkshop);

                            //trWorkshopPDF.Controls.Add(tcWorkshopPDF);
                            #endregion
                            // policy
                            HtmlTableCell tcPolicyPDF = new HtmlTableCell();
                            tcPolicyPDF.Attributes.Add("class", "bg_grey_2 pad7px");
                            tcPolicyPDF.InnerText = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["MedicalExpense"].ToString()));
                            trPolicy.Controls.Add(tcPolicyPDF);

                            #region remove
                            //string _policyId = "test";// dtFiltered.Rows[iRows]["NInfo1"].ToString();

                            //ProviderPolicyDocument _policydoc = new ProviderPolicyDocument();
                            //ProviderPolicyDocumentDB _policydocdb = new ProviderPolicyDocumentDB();

                            ////_policydoc = _policydocdb.GetProviderPolicyDocument(Convert.ToInt64(_policyId));

                            //string docurl = _policydoc.UploadPath;
                            //HyperLink _lnkTest = new HyperLink();
                            //_lnkTest.NavigateUrl = docurl;

                            //HyperLink hplnkPolicyDoc = new HyperLink();
                            //hplnkPolicyDoc.ImageUrl = "~/images/icon/pdf.png";
                            //hplnkPolicyDoc.NavigateUrl = _lnkTest.ResolveClientUrl(docurl);
                            //hplnkPolicyDoc.Target = "_blank";

                            //tcPolicyPDF.Controls.Add(hplnkPolicyDoc);
                            //trPolicy.Controls.Add(tcPolicyPDF);
                            #endregion

                            //endorsements
                            HtmlTableCell tcEndorsement = new HtmlTableCell();
                            tcEndorsement.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad7px");
                            tcEndorsement.InnerText = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["BailBond"].ToString()));
                            trEndorsement.Controls.Add(tcEndorsement);

                            #region remove
                            //HyperLink hlnkEndorsements = new HyperLink();
                            //hlnkEndorsements.ImageUrl = "~/images/icon/pdf.png";
                            //hlnkEndorsements.Target = "_blank";

                            //int _coverid = Convert.ToInt32(dtFiltered.Rows[iRows]["CoverTypeId"].ToString());

                            //if (_providercompanyid == "23")
                            //{
                            //    if (_coverid == 2 || _coverid == 6) //classic
                            //    {
                            //        hlnkEndorsements.NavigateUrl = "~/policy_docs/HSBC/PCIClassicPlan.pdf";
                            //    }
                            //    else
                            //    {
                            //        hlnkEndorsements.NavigateUrl = "~/policy_docs/HSBC/PCIPremierPlan.pdf";
                            //    }

                            //    tcEndorsement.Controls.Add(hlnkEndorsements);
                            //}

                            //trEndorsement.Controls.Add(tcEndorsement);
                            #endregion

                            //bottom
                            HtmlTableCell tcBottomNew = new HtmlTableCell();
                            tcBottomNew.Attributes.Add("class", "bg_grey_2 w210px");

                            HtmlGenericControl divBottomNew = new HtmlGenericControl("div");

                            HtmlGenericControl divBottomNew1 = new HtmlGenericControl("div");
                            divBottomNew1.Attributes.Add("class", "curvebottomleft left");

                            HtmlGenericControl divBottomNew2 = new HtmlGenericControl("div");
                            divBottomNew2.Attributes.Add("class", "curvebottomright right");

                            divBottomNew.Controls.Add(divBottomNew1);
                            divBottomNew.Controls.Add(divBottomNew2);

                            tcBottomNew.Controls.Add(divBottomNew);

                            trBottom.Controls.Add(tcBottomNew);

                            //Interested Bar

                            if (rowCount == 2)
                            {
                                divBar.Style.Add("width", "502px");
                                divCenterBar.Style.Add("width", "480px");
                                tdBarLeft.Width = "372px";
                            }
                            else if (rowCount == 3)
                            {
                                divBar.Style.Add("width", "613px");
                                divCenterBar.Style.Add("width", "590px");
                                //tdBarLeft.Style.Add("class", "w322px");
                                tdBarLeft.Width = "265px";
                            }
                            else if (rowCount == 4)
                            {
                                divBar.Style.Add("width", "693px");
                                divCenterBar.Style.Add("width", "680px");
                                tdBarLeft.Width = "182px";
                            }


                            //BAR/ARROWS
                            HtmlTableCell tcArrows = new HtmlTableCell();
                            tcArrows.Attributes.Add("class", "txtcenter w210px");
                            tcArrows.Attributes.Add("valign", "center");
                            Image imgArrows = new Image();
                            imgArrows.ImageUrl = "/images/form/icon_arrow_down.png";
                            imgArrows.Width = 30;
                            imgArrows.Height = 20;


                            tcArrows.Controls.Add(imgArrows);
                            trArrows.Controls.Add(tcArrows);

                            //OPTIONS

                            //top
                            if (rowCount == 2)
                            {
                                tdTopPad.Attributes.Add("class", "w312px");
                            }
                            else if (rowCount == 3)
                            {
                                tdTopPad.Attributes.Add("class", "w400px");
                            }
                            else if (rowCount == 4)
                            {
                                tdTopPad.Attributes.Add("class", "w480px");
                            }


                            HtmlTableCell tcTopOptions = new HtmlTableCell();
                            tcTopOptions.Attributes.Add("class", "bg_grey_2 w200px");

                            HtmlGenericControl divTopOption = new HtmlGenericControl("div");

                            HtmlGenericControl divTopOption1 = new HtmlGenericControl("div");
                            divTopOption1.Attributes.Add("class", "curvetopleft left");

                            HtmlGenericControl divTopOption2 = new HtmlGenericControl("div");
                            divTopOption2.Attributes.Add("class", "curvetopright right");

                            divTopOption.Controls.Add(divTopOption1);
                            divTopOption.Controls.Add(divTopOption2);

                            tcTopOptions.Controls.Add(divTopOption);

                            trTopOptions.Controls.Add(tcTopOptions);

                            string _citempresultid = dtFiltered.Rows[iRows]["CITempResultId"].ToString();
                            string _companyName = "";

                            if (_providercompanyid == "11")
                            {
                                _companyName = "AZCP Insurance";
                            }
                            else if (_providercompanyid == "29")
                            {
                                _companyName = "LMG Insurance";
                            }
                            else if (_providercompanyid == "12")
                            {
                                _companyName = "MSIG Insurance";
                            }
                            else if (_providercompanyid == "16")
                            {
                                _companyName = "AXA Insurance";
                            }
                            else if (_providercompanyid == "31")
                            {
                                _companyName = "Chartis Insurance";
                            }
                            else if (_providercompanyid == "32")
                            {
                                _companyName = "Bangkok Insurance";
                            }
                            else if (_providercompanyid == "41")
                            {
                                _companyName = "Kurnia Insurance";
                            }

                            //buy online me
                            HtmlTableCell tcBuyOnline = new HtmlTableCell();
                            tcBuyOnline.Attributes.Add("class", "bg_grey_2 border2pxdotb pad7pxtb");
                            Button btnBuyOnline = new Button();
                            btnBuyOnline.ID = "btnBuyOnline" + rowCount.ToString() + iRows.ToString();
                            btnBuyOnline.CssClass = "button_buy-now";
                            btnBuyOnline.CommandArgument = _providercompanyid + "," + _citempresultid;
                            btnBuyOnline.Command += new CommandEventHandler(btnBuyNow_Click);
                            btnBuyOnline.OnClientClick = "this.removeAttribute('onmouseout');this.removeAttribute('onmouseup'); this.className = 'button_processing';";

                            tcBuyOnline.Controls.Add(btnBuyOnline);
                            trBuyOnline.Controls.Add(tcBuyOnline);


                            //call me
                            HtmlTableCell tcCallMe = new HtmlTableCell();
                            tcCallMe.Attributes.Add("class", "bg_grey_2 border2pxdotb pad7pxtb");

                            if (_providercompanyid != "23")
                            {
                                Button btnCallMe = new Button();
                                btnCallMe.Attributes.Add("class", "button_call-me");
                                btnCallMe.ValidationGroup = "callme";

                                tcCallMe.Controls.Add(btnCallMe);

                                //check for call me status
                                if ((Session[General.AgentId] == null)
                                        && Convert.ToInt32(Session[CE.Global.General.UserTypeId]) ==
                                        Convert.ToInt32(CE.Global.CEUserType.Customer))
                                {
                                    ContactUser _cu = new ContactUser();
                                    ContactUserDB _cudb = new ContactUserDB();

                                    _cu = _cudb.GetCallMe(Convert.ToInt64(Session[General.UserId].ToString()), Convert.ToInt64(Session[General.CarId].ToString()), "CI", Convert.ToInt64(_providercompanyid));

                                    if (_cu != null)
                                    {
                                        //btnCallMe.OnClientClick = "javascript:void(0);alert('You have already requested to call you.'  + '\\r\\n' + 'Please wait a while to get call from them. Thank you.')";
                                        btnCallMe.OnClientClick = "javascript:void(0);ShowPopup('" + _providercompanyid + "', '" + _citempresultid + "', '" + _companyName + "', 'true');return false;";
                                    }
                                    else
                                    {
                                        btnCallMe.OnClientClick = "javascript:void(0);ShowPopup('" + _providercompanyid + "', '" + _citempresultid + "', '" + _companyName + "', 'true');return false;";
                                    }
                                }

                            }
                            trCallMe.Controls.Add(tcCallMe);

                            //email me
                            HtmlTableCell tcEmailMe = new HtmlTableCell();
                            tcEmailMe.Attributes.Add("class", "bg_grey_2 border2pxdotb pad7pxtb");

                            Button btnEmailMe = new Button();
                            btnEmailMe.CssClass = "button_view-garage";                         
                            
                            btnEmailMe.OnClientClick = "ValidateRedirect('" + _providercompanyid + "')";
                                     
                            //btnEmailMe.OnClientClick = "javascript:void(0);ShowPopup('" + _providercompanyid + "', '" + _citempresultid + "', '" + _companyName + "', 'false');return false;";

                            tcEmailMe.Controls.Add(btnEmailMe);
                            trEmailMe.Controls.Add(tcEmailMe);


                            //email this
                            HtmlTableCell tcEmailThis = new HtmlTableCell();
                            tcEmailThis.Attributes.Add("class", "bg_grey_2 border2pxdotb pad7pxtb");

                            Button btnEmailThis = new Button();
                            btnEmailThis.CssClass = "button_email-this";
                            btnEmailThis.ID = "btnEmailThis" + rowCount.ToString() + iRows.ToString();
                            btnEmailThis.CommandArgument = _providercompanyid + "," + _citempresultid;
                            btnEmailThis.Command += new CommandEventHandler(btnEmailThis_Click);
                            btnEmailThis.OnClientClick = "this.removeAttribute('onmouseout');this.removeAttribute('onmouseup'); this.className = 'button_processing';";

                            tcEmailThis.Controls.Add(btnEmailThis);
                            trEmailThis.Controls.Add(tcEmailThis);


                            //bottom
                            HtmlTableCell tcBottomOptions = new HtmlTableCell();
                            tcBottomOptions.Attributes.Add("class", "bg_grey_2 w210px");

                            HtmlGenericControl divBottomOption = new HtmlGenericControl("div");

                            HtmlGenericControl divBottomOption1 = new HtmlGenericControl("div");
                            divBottomOption1.Attributes.Add("class", "curvebottomleft left");

                            HtmlGenericControl divBottomOption2 = new HtmlGenericControl("div");
                            divBottomOption2.Attributes.Add("class", "curvebottomright right");

                            divBottomOption.Controls.Add(divBottomOption1);
                            divBottomOption.Controls.Add(divBottomOption2);

                            tcBottomOptions.Controls.Add(divBottomOption);

                            trBottomOptions.Controls.Add(tcBottomOptions);
                        }

                    }
                }
            }
            else
            {
                //Response.Redirect("results-new.aspx");
                Response.Redirect("~/car-insurance/sign-in.aspx");
            }
        }
        else
        {
            Response.Redirect("~/car-insurance/sign-in.aspx");
        }

    }

    private bool SendMailToUserNEWDetails()
    {
        CE.User.Profile usrprofile = new Profile();
        ProfileDB usrprofiledb = new ProfileDB();

        usrprofile = usrprofiledb.GetProfile(Convert.ToInt64(Session[General.UserId].ToString()));

        string userfirstname = "";

        if (usrprofile != null)
        {
            userfirstname = usrprofile.FirstName;
        }

        bool _retVal = false;
        string _strCXLive = CE.Configuration.MyConfigurationManager.GetAppSettingValue("TH.IsCXLive");

        string _emailTo = Session[General.UserEmail].ToString();
        string _customername = Session[General.UserName].ToString();
        string _emailSubject = Resources.EmailMessage.Subject; //"Your Car Insurance Quotes on CompareXpress(Thailand)";
        string _mailBody = "";
        //string _currentDomainUrl = "http://" + HttpContext.Current.Request.Url.Host.ToString();
        string _currentDomainUrl = "http://www.gluaygluay.com";
        string imgLogoUrl = _currentDomainUrl + CE.Configuration.MyConfigurationManager.GetAppSettingValue("TH.LogoPath");

        _mailBody = "<body class='email_body'>";
        _mailBody += "<style type='text/css'>";
        _mailBody += ".email_body {background:white;margin:0; padding:0; color:#4c4c4c; font-family:Arial, Helvetica, sans-serif; font-size:0.85em;}";
        _mailBody += "a {text-decoration:underline;color:#2c95cc;} ";
        _mailBody += "#email_container {margin:0 auto;padding:20px;width:600px; height:auto;} ";
        _mailBody += "#email_body {width:100%; text-align: left !important;} ";
        _mailBody += ".email_pad10px {padding:10px;} ";
        _mailBody += ".email_results td {width:33%;} ";
        _mailBody += "</style>";
        _mailBody += "<center>";

        _mailBody += "<table cellpadding='0' cellspacing='0' border='0' style='padding:20px;' width='600'>";
        _mailBody += "<tr><td width='360'><a href='http://www.gluaygluay.com/car-insurance/sign-in.aspx' target='_blank'><img src='" + _currentDomainUrl + "/images/email/header_quote.png' width='596' height='187' alt='GluayGluay.com' border='0' /></a></td></tr>";
        //_mailBody += "<tr><td style='padding-left:45px; padding-right:45px;'><strong>Dear " + Session[General.UserName].ToString() + ",</strong><br/><br/>";

        _mailBody += "<tr><td style='padding-left:45px; padding-right:45px;'>";
        _mailBody += "<strong>" + Resources.EmailMessage.Dear + userfirstname + ",</strong><br/><br/>";
        _mailBody += Resources.EmailMessage.Thankyou + "<br/><br/>";
        _mailBody += Resources.EmailMessage.RequestedQuote + "<br/><br/>";

        DataView dvResults = new DataView((DataTable)Cache["CarResult" + Session[General.UserId].ToString() + Session[General.CarId].ToString()]);

        _mailBody += "<table cellpadding='5' cellspacing='0' border='0' width='546px' class='table_details'>";

        string CITempResultId = inputCarResultId.Value;
        dvResults.RowFilter = " CITempResultId in (" + CITempResultId + ")";

        DataTable dtResults = dvResults.ToTable();


        if (dtResults.Rows.Count > 0)
        {
            string _providercompanyid = dtResults.Rows[0]["providercompanyid"].ToString();
            //logo
            string logourl = CE.Global.General.GetProviderCompanyLogo(_providercompanyid);

            _mailBody += "<tr>";
            _mailBody += "<td width='45%'></td>";
            _mailBody += "<td width='55%' align='center' style='background:#e0e0e0; border-bottom:white 1px dashed;'><img src='" + _currentDomainUrl + logourl + "' width='130' style='padding:3px;'/></td>";
            _mailBody += "</tr>";

            string insurername = dtResults.Rows[0]["PackageName"].ToString();

            //insurer name
            _mailBody += "<tr>";
            _mailBody += "<td><strong>" + Resources.CarInsuranceResultPage.Insurer + "</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5; color:white;'><strong>" + insurername + "</strong></td>";
            _mailBody += "</tr>";

            //premium
            _mailBody += "<tr>";
            _mailBody += "<td align='left' style='background:#d5d5d5' ><strong>" + Resources.CarInsuranceResultPage.TotalVMI + "</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5; color:black; font-size:20px;'>";
            if (Convert.ToSingle(dtResults.Rows[0]["annualpremium"]) != Convert.ToSingle(dtResults.Rows[0]["PromotionPrice"]))
            {
                _mailBody += "<s>" + String.Format("{0:0,0.00}", Convert.ToSingle(dtResults.Rows[0]["annualpremium"].ToString())) + "</s>";
            }
            _mailBody += "<br/><strong>" + String.Format("{0:0,0.00}", Convert.ToSingle(dtResults.Rows[0]["PromotionPrice"].ToString())) + "</strong>";
            _mailBody += "</td>";
            _mailBody += "</tr>";

            float _fMonthlyPremiumAmount = Convert.ToSingle(dtResults.Rows[0]["MonthlyPremiumAmount"].ToString());
            string monthlyInstallment = "";

            if (_fMonthlyPremiumAmount > 0.0f)
            {
                string _monthlyPremiumAmount = String.Format("{0:0,0.00}", _fMonthlyPremiumAmount);
                monthlyInstallment = _monthlyPremiumAmount + "/mth<br/>";
            }
            else
            {
                monthlyInstallment = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            //installment
            //_mailBody += "<tr>";
            //_mailBody += "<td><strong>" + Resources.CarInsuranceResultPage.MonthlyInstallment + " <br/>4-mth 0% Interest Free</strong></td>";
            //_mailBody += "<td align='center' style='background:#d5d5d5' >" + monthlyInstallment + "</td>";
            //_mailBody += "</tr>";

            //Deductible  
            _mailBody += "<tr>";
            _mailBody += "<td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.DEC + "</strong></td>";
            float _fDEC = Convert.ToSingle(dtResults.Rows[0]["DEC"].ToString());
            string deductible = "";
            if (_fDEC > 0.0f)
            {
                deductible = String.Format("{0:0,0.00}", _fDEC);
            }
            else
            {
                deductible = Resources.CarInsuranceResultPage.Waived;  //"<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + deductible + "</td>";
            _mailBody += "</tr>";

            string suminsured = String.Format("{0:#,0}", Convert.ToSingle(dtResults.Rows[0]["SumInsured"].ToString()));
            if (suminsured == "0")
            {
                suminsured = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }
            //Own Damage
            _mailBody += "<tr>";
            _mailBody += "<td><strong>" + Resources.CarInsuranceResultPage.OwnDamage + "</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + suminsured + "</td>";
            _mailBody += "</tr>";

            //Fire
            string fire = String.Format("{0:#,0}", Convert.ToSingle(dtResults.Rows[0]["Fire"].ToString()));
            if (fire == "0")
            {
                fire = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }
            _mailBody += "<tr>";
            _mailBody += "<td><strong>" + Resources.CarInsuranceResultPage.Fire + "</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + fire + "</td>";
            _mailBody += "</tr>";

            //Theft
            string theft = String.Format("{0:#,0}", Convert.ToSingle(dtResults.Rows[0]["Theft"].ToString()));
            if (theft == "0")
            {
                theft = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }
            _mailBody += "<tr>";
            _mailBody += "<td><strong>" + Resources.CarInsuranceResultPage.Theft + "</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + theft + "</td>";
            _mailBody += "</tr>";

            //TPPD
            _mailBody += "<tr>";
            _mailBody += "<td><strong>" + Resources.CarInsuranceResultPage.TPPD + "</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + String.Format("{0:#,0}", Convert.ToSingle(dtResults.Rows[0]["TPPD"].ToString())) + "</td>";
            _mailBody += "</tr>";

            //TPBIA
            _mailBody += "<tr>";
            _mailBody += "<td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.TPBIA + "</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + String.Format("{0:#,0}", Convert.ToSingle(dtResults.Rows[0]["TPBIA"].ToString())) + "</td>";
            _mailBody += "</tr>";

            //TPBIP
            _mailBody += "<tr>";
            _mailBody += "<td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.TPBIP + "</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + String.Format("{0:#,0}", Convert.ToSingle(dtResults.Rows[0]["TPBIP"].ToString())) + "</td>";
            _mailBody += "</tr>";

            //PA Driver
            _mailBody += "<tr>";
            _mailBody += "<td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.PADriver + "</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + String.Format("{0:#,0}", Convert.ToSingle(dtResults.Rows[0]["PADriver"].ToString())) + "</td>";
            _mailBody += "</tr>";


            int _MedicalExpense = Convert.ToInt32(dtResults.Rows[0]["MedicalExpense"].ToString());
            string medicalExpense = "";

            if (_MedicalExpense == 0)
            {
                medicalExpense = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }
            else
            {
                medicalExpense = String.Format("{0:#,0}", Convert.ToSingle(_MedicalExpense.ToString()));
            }

            //Medical Expense
            _mailBody += "<tr>";
            _mailBody += "<td><strong>" + Resources.CarInsuranceResultPage.MED + "</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + medicalExpense + "</td>";
            _mailBody += "</tr>";

            //BB
            _mailBody += "<tr>";
            _mailBody += "<td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.BailBond + "</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + String.Format("{0:#,0}", Convert.ToSingle(dtResults.Rows[0]["BailBond"].ToString())) + "</td>";
            _mailBody += "</tr>";

        }

        _mailBody += "</table>";
        _mailBody += "<br/><br/>" + Resources.EmailMessage.Details + "<br/><br/>";
        _mailBody += " <a href='http://www.gluaygluay.com/car-insurance/sign-in.aspx'>www.GluayGluay.com</a> <br/><br/>";

        //_mailBody += "Enter your Email and Password as follows: <br/>";

        //Account _account = new Account();
        //AccountDB _accountdb = new AccountDB();
        //_account = _accountdb.GetAccount(Convert.ToInt64(Session[General.UserId].ToString()));
        //if (_account != null)
        //{
        //    _mailBody += "<br /> User Name : " + Session[General.UserEmail].ToString();
        //    _mailBody += "<br /> Password : " + _account.AuthCode + "<br/><br/>";

        //}


        _mailBody += "</td></tr>";
        _mailBody += "<tr><td id='email_footer'><a href='http://www.gluaygluay.com' target='_blank'><img src='" + _currentDomainUrl + "/images/email/footer_quote.png' alt='GluayGluay.com - Partners' width='596' border='0' /></a>";
        _mailBody += "</td></tr></table>";

        _mailBody += "<hr />";
        _mailBody += Resources.EmailMessage.Footer;
        _mailBody += "<br/>";
        _mailBody += "<br /><i>" + Resources.EmailMessage.NoReply + "</i>";
        _mailBody += "<hr />";
        _mailBody += "</center></body>";

        if (MyMailManager.SendCARMessage(_emailTo, _emailSubject, _mailBody))
        {
            _retVal = true;
        }
        else
        {
            _retVal = false;
        }

        return _retVal;
    }

    private void CarUserOptionLog(bool isBuyNow, bool isCallMe, bool isEmailMe)
    {
        CarUserOption caruseroption = new CarUserOption();
        CarUserOptionDB caruseroptiondb = new CarUserOptionDB();

        caruseroption.CarUserOptionId = 0;
        caruseroption.CECarId = Convert.ToInt64(Session[General.CarId].ToString());
        caruseroption.IsBuyNow = isBuyNow;
        caruseroption.IsCallMe = isCallMe;
        caruseroption.IsEmailMe = isEmailMe;
        caruseroption.IsEmailThis = false;
        caruseroption.RecipientName = "";
        caruseroption.RecipientEmailAddress = "";
        caruseroption.ViewedDetailId = 0;
        caruseroption.RefCEUserId = Convert.ToInt64(Session[General.UserId].ToString());

        caruseroptiondb.Insert(caruseroption);
    }

    protected void btnBuyNow_Click(object sender, CommandEventArgs e)
    {
        string _providerID = "";
        string _carresultID = "";
        string[] _ids = e.CommandArgument.ToString().Split(',');

        _providerID = _ids[0].ToString();
        _carresultID = _ids[1].ToString();

        CarDetailTHDB cardetail = new CarDetailTHDB();
        Boolean language = cardetail.UpdateLanguage(Convert.ToInt64(Session[General.CarId]), Session["Language"].ToString());

        Session[CE.Global.General.CarResultId] = _carresultID;
        Session[CE.Global.General.ProviderCompanyId] = _providerID;
        Session["FromSummary"] = "0";
        CarUserOptionLog(true, false, false);
        _redirectUrl = CE.Global.General.GetProviderProposalUrl(_providerID, Page);
        Response.Redirect(_redirectUrl);

    }

    protected void btnCallMe_Click(object sender, EventArgs e)
    {
        string _providerID = "";
        _providerID = inputProviderId.Value.Trim();

        Session[CE.Global.General.CarResultId] = inputCarResultId.Value.Trim();
        Session[CE.Global.General.ProviderCompanyId] = _providerID;

        if ((Session[General.AgentId] == null)
                && Convert.ToInt32(Session[CE.Global.General.UserTypeId]) ==
                Convert.ToInt32(CE.Global.CEUserType.Customer))
        {
            ContactUser _cu = new ContactUser();
            ContactUserDB _cudb = new ContactUserDB();

            _cu = _cudb.GetCallMe(Convert.ToInt64(Session[General.UserId].ToString()), Convert.ToInt64(Session[General.CarId].ToString()), "CI", Convert.ToInt64(_providerID));

            if (_cu != null)
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "Alert", "alert('You have already requested to call you.'  + '\\r\\n' + 'Please wait a while to get call from them. Thank you.')", true);
            }
            else
            {
                if (Session[CE.Global.General.UserId] != null && Session[CE.Global.General.CarId] != null)
                {
                    string _message = "";
                    string _title = "";
                    string _ec = "";
                    txtFullName.Text = General.ClearScriptTag(txtFullName.Text);
                    _message = "Customer Name: " + txtFullName.Text;
                    _title = "Call Me request by " + txtFullName.Text + " for " + inputCallMeCompanyName.Value;
                    //ChangeValidationEffectServerSide("callme");
                    if (IsValid)
                    {
                        Int64 _result = 0;
                        ContactUser _contactuser = new ContactUser();
                        ContactUserDB _contactuserdb = new ContactUserDB();

                        _contactuser.RefCEUserId = Convert.ToInt64(Session[General.UserId].ToString());
                        _contactuser.ProductId = Convert.ToInt64(Session[General.CarId].ToString());

                        if (_providerID == "11") //AZCP
                        {
                            _contactuser.ProviderCompanyId = 11;
                            _ec = "1011";
                        }
                        else if (_providerID == "12")//MSIG
                        {
                            _contactuser.ProviderCompanyId = 12;
                            _ec = "1012";
                        }
                        else if (_providerID == "16")//AXA
                        {
                            _contactuser.ProviderCompanyId = 16;
                            _ec = "1016";
                        }
                        else if (_providerID == "29")//LMG
                        {
                            _contactuser.ProviderCompanyId = 29;
                            _ec = "1029";
                        }
                        else if (_providerID == "31")//Chartis
                        {
                            _contactuser.ProviderCompanyId = 31;
                            _ec = "1031";
                        }
                        else if (_providerID == "32")//BKI
                        {
                            _contactuser.ProviderCompanyId = 32;
                            _ec = "1032";
                        }
                        else if (_providerID == "41")//Kurnia
                        {
                            _contactuser.ProviderCompanyId = 41;
                            _ec = "1041";
                        }
                        _contactuser.InsuranceType = "CI";
                        _contactuser.FullName = txtFullName.Text.Trim();
                        _contactuser.ContactNo = txtMobileNo.GetPhoneNo();
                        _contactuser.CallTime = Convert.ToInt16(ddlCallMeTime.Text);
                        _contactuser.AgentId = 0;
                        _contactuser.Status = true;

                        _result = _contactuserdb.Insert(_contactuser);
                        if (_result > 0)
                        {
                            //Sakthi on 29 Jun 2011 (Alternative mail sending) -- Start
                            CXAgent _cxagent = new CXAgent();
                            CXAgentDB _cxagentdb = new CXAgentDB();
                            Int64 _ProductId = 0;
                            Int64 _AgentId = 0;
                            Int64 _CEID = Convert.ToInt64(Session[General.UserId].ToString());
                            string _AgentName = "";
                            string _AgentEmail = "";
                            string _CCEmail = "";
                            string _BCCEmail = "";
                            DataTable _dtCXAgent = _cxagentdb.GetCXAgentList(_CEID, "CM", 0);
                            if (_dtCXAgent != null && _dtCXAgent.Rows.Count > 0)
                            {
                                _AgentId = Convert.ToInt64(_dtCXAgent.Rows[0]["AgentId"].ToString());
                                _AgentName = _dtCXAgent.Rows[0]["AgentName"].ToString();
                                _AgentEmail = _dtCXAgent.Rows[0]["Email"].ToString();

                                _ProductId = Convert.ToInt64(Session[General.CarId].ToString());
                                _contactuserdb.Update(_CEID, _AgentId, _contactuser.ProviderCompanyId, "CM", _ProductId);

                                _message += "<br/><br/>Make/Model : " + inputCallMeMakeModel.Value;
                                _message += "<br/><br/><b>Insurer : <span style='color:#f00'>" + inputCallMeCompanyName.Value;
                                _message += "</span></b><br/><br/>Contact No : " + txtMobileNo.GetPhoneNo();
                                _message += "<br/><br/>Call Time : " + ddlCallMeTime.SelectedItem.Text;
                                _message += "<br/><br/>Agent Name : " + _AgentName;
                                //string _emailList = ConfigurationManager.AppSettings["CICallMeMessageReceiver"].ToString();
                                //MyMailManager.SendCRMMessage(_emailList, _title, _message);
                                _CCEmail = ConfigurationManager.AppSettings["TH.CC_CICallMeMessageReceiver"].ToString();
                                _BCCEmail = ConfigurationManager.AppSettings["TH.BCC_CICallMeMessageReceiver"].ToString();
                                //MyMailManager.SendCallMeMessage(_AgentEmail, _CCEmail, _BCCEmail, _title, _message);
                                MyMailManager.SendCallMeMessage(_CCEmail, "", _BCCEmail, _title, _message);
                               
                                CarUserOptionLog(false, true, false);

                                Session["UMMSG"] = "CI," + _ec.ToString();
                                _redirectUrl = CE.Global.General.GetUrl("~/user/usermessage.aspx", Page);
                                Response.Redirect(_redirectUrl);
                            }
                            //Sakthi on 29 Jun 2011 (Alternative mail sending) -- End
                        }
                    }
                }
            }

        }

    }

    protected void btnEmailMe_Click(object sender, EventArgs e)
    {
        string _providerID = "";
        _providerID = inputProviderId.Value.Trim();

        Session[CE.Global.General.CarResultId] = inputCarResultId.Value.Trim();
        Session[CE.Global.General.ProviderCompanyId] = _providerID;

        string _ec = "1100";

        //if (_providerID == "23")
        //{
        //    _ec = "1123";
        //}
        //else if (_providerID == "29")
        //{
        //    _ec = "1129";
        //}
        //else if (_providerID == "30")
        //{
        //    _ec = "1130";
        //}

        if (SendMailToUserNEWDetails())
        {
            CarUserOptionLog(false, false, true);
            Session["FromSummary"] = "0";
            //Response.Redirect("~/user/usermessage.aspx?mt=CI&ec=" + _ec);
            Session["UMMSG"] = "CI," + _ec.ToString();
            _redirectUrl = CE.Global.General.GetUrl("~/car-insurance/email-usermessage.aspx", Page);
            Response.Redirect(_redirectUrl);
        }


    }

    protected void btnEmailThis_Click(object sender, CommandEventArgs e)
    {
        string _providerID = "";
        string _carresultID = "";
        string[] _ids = e.CommandArgument.ToString().Split(',');

        _providerID = _ids[0].ToString();
        _carresultID = _ids[1].ToString();

        Session[CE.Global.General.CarResultId] = _carresultID;
        Session[CE.Global.General.ProviderCompanyId] = _providerID;
        Session["FromSummary"] = "0";

        _redirectUrl = CE.Global.General.GetUrl("~/car-insurance/email-this.aspx", Page);
        Response.Redirect(_redirectUrl);

    }

    protected void btnBack_Click(object sender, EventArgs e)
    {
        _redirectUrl = CE.Global.General.GetUrl("~/car-insurance/quote-results.aspx", Page);
        Response.Redirect(_redirectUrl);


    }
}

